package org.shana.shortlink.admin.config;

import lombok.extern.slf4j.Slf4j;
import org.shana.shortlink.admin.common.convention.result.Result;
import org.shana.shortlink.admin.common.convention.result.Results;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class WebExceptionAdvice {
    WebExceptionAdvice(){
        System.out.println("*****************************");
        System.out.println("初始化");
    }

    @ExceptionHandler(RuntimeException.class)
    public Result handleRuntimeException(RuntimeException e) {
        log.error(e.toString(), e);
        return Results.failure("服务器异常","error");
    }
}
